/*
 * Copyright(c) 2018 优居科技 All rights reserved.
 * distributed with this file and available online at
 * http://www.yjyz.com/
 */
package com.zb.api.business.controller;

import com.zb.api.business.dto.PosMerchantDto;
import com.zb.api.business.dto.UserDesignerDto;
import com.zb.api.business.service.IPosMerchantService;
import com.zb.api.common.models.Page;
import com.zb.api.common.models.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
* 商户表
 *
 * @author cwp
 * @version v1.0
 * @CreationTime: - 2022-02-08 14:19:30
 * @Description:
 */
@Api("商户表")
@RestController
@Slf4j
@RequestMapping("/posMerchant")
public class PosMerchantController {

    @Resource
    private IPosMerchantService posMerchantService;

    @GetMapping("/lists")
    @ApiOperation(value="获取分页商户表数据", nickname = "posMerchantList")
    public Result<Page<PosMerchantDto>> posMerchantList(@RequestParam(defaultValue = "1") @ApiParam(name = "pageNo", value = "当前页") int pageNo,
                                                        @RequestParam(defaultValue = "10") @ApiParam(name = "pageSize", value = "每页记录数") int pageSize,
                                                        PosMerchantDto posMerchantDto){
        return new Result("查询成功", posMerchantService.getPosMerchantList(pageNo, pageSize, posMerchantDto));
    }

    @GetMapping("/{id}")
    @ApiOperation(value="获取商户表", nickname = "getPosMerchant")
    public Result<PosMerchantDto> getPosMerchant(@PathVariable("id") String id) {
        return new Result("查询成功", posMerchantService.get(id));
    }

    @PutMapping
    @ApiOperation(value="更新商户表", nickname = "updatePosMerchant")
    public Result<Integer> updatePosMerchant(@RequestBody PosMerchantDto posMerchantDto) {
        return new Result("修改成功", posMerchantService.update(posMerchantDto));
    }

    @PostMapping
    @ApiOperation(value="插入商户表", nickname = "insertPosMerchant")
    public Result<Integer> insertPosMerchant( @RequestBody PosMerchantDto posMerchantDto) {
        return new Result("录入成功", posMerchantService.insert(posMerchantDto));
    }

    @PostMapping("/registerMerchant")
    @ApiOperation(value="注册商户", nickname = "registerMerchant")
    public Result<Integer> registerMerchant(@RequestBody PosMerchantDto posMerchantDto) throws IllegalAccessException {
        return new Result("注册成功", posMerchantService.registerMerchant(posMerchantDto));
    }

    @PostMapping("/updateMerchant")
    @ApiOperation(value="更新商户表", nickname = "updateMerchant")
    public Result<Integer> updateMerchant(@RequestBody PosMerchantDto posMerchantDto) {
        return new Result("修改成功", posMerchantService.update(posMerchantDto));
    }

    @PostMapping("/addDesigner")
    @ApiOperation(value="添加设计师", nickname = "addDesigner")
    public Result<Integer> addDesigner( @RequestBody UserDesignerDto userDesignerDto) {
        return new Result("录入成功", posMerchantService.addDesigner(userDesignerDto));
    }

    @GetMapping("/delDesigner/{id}")
    @ApiOperation(value="删除设计师", nickname = "delDesigner")
    public Result<Integer> delDesigner(@PathVariable("id") String id) {
        return new Result("录入成功", posMerchantService.delDesigner(id));
    }

    @PostMapping("/getDesignerList")
    @ApiOperation(value="商户设计师列表", nickname = "getDesignerList")
    public Result<List<UserDesignerDto>> getDesignerList(@RequestBody UserDesignerDto userDesignerDto) {
        return new Result("查询成功", posMerchantService.getDesignerList(userDesignerDto));
    }

}
